package com.yufeng.collaboration.controller;

import com.yufeng.collaboration.entity.Notice;
import com.yufeng.collaboration.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/notices")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    @GetMapping("/{receiverId}")
    public List<Notice> getNoticesByReceiverId(@PathVariable String receiverId) {
        return noticeService.getNoticesByReceiverId(receiverId);
    }

    @PostMapping
    public void addNotice(@RequestBody Notice notice) {
        noticeService.addNotice(notice);
    }

    @DeleteMapping("/{id}")
    public void deleteNotice(@PathVariable Integer id) {
        noticeService.deleteNotice(id);
    }
}
